<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const str = 'abc'
        console.log(str.repeat(2)) //abcabc
        console.log(str.repeat(2.8)) //abcabc
        console.log(str.repeat(0)) //''
        console.log(str.repeat(0.5)) //''
        console.log(str.repeat(-0.5)) //''
        // console.log(str.repeat(-1)) //报错
        // console.log(str.repeat(Infinity)) //报错
        console.log(str.repeat('2')) //abcabc
        console.log(str.repeat('abc')) //''
        console.log(str.repeat(true)) //'abc'
        console.log(str.repeat(false)) //''
        console.log(str.repeat(null)) //''
        console.log(str.repeat(undefined)) //''
        console.log(str.repeat(NaN)) //''
    </script>
</body>
</html>